<!--
 * @Author: wjk
 * @Date: 2019-11-18 16:48:07
 * @LastEditors  : wjk
 * @LastEditTime : 2020-01-16 13:36:05
 * @description: file content
 -->
<template>
  <view class="global-components">
    <g-loading ref="loading"></g-loading>
    <g-message ref="message"></g-message>
    <g-error ref="error"></g-error>
    <g-toast ref="toast"></g-toast>
  </view>
</template>

<script>
import gLoading from './gc-loading/gc-loading'
import gMessage from './gc-message/gc-message'
import gError from './gc-error-page/gc-error'
import gToast from './gc-toast/gc-toast'
export default {
  name: 'GbobalComponents',
  components: {
    gLoading,
    gMessage,
    gError,
    gToast
  },
  data() {
    return {

    }
  },
  onReady() {
    this.$gc.$loading = this.$refs.loading.show
    this.$gc.$message = this.$refs.message.show
    this.$gc.toast = this.$refs.toast.show
    // #ifdef MP-WEIXIN
    uni.$on('showToast', (msg) => {
      this.$refs.toast.show(msg)
    })
    // #endif
  },
  // #ifdef H5
  mounted() {
    // console.log(this.$refs.loading)
    this.$gc.$loading = this.$refs.loading.show
    this.$gc.$message = this.$refs.message.show
    this.$gc.toast = this.$refs.toast.show
    // console.log(this.$gc)
    // console.log('this.$refs.loading', this.$refs.loading)
  }
  // #endif

}
</script>

<style lang="scss" scoped>
.global-components{
  position: absolute;
  right: 100%;
  top: 100%;
}
</style>
